package com.example.demo.config;

import com.example.demo.entity.Car;
import com.example.demo.entity.Driver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * Component和Configuration的区别
 * https://blog.csdn.net/q410654146/article/details/108171142
 * https://wenku.baidu.com/view/abc75509463610661ed9ad51f01dc281e43a565d.html
 */
@Configuration
//@Component
public class ConfigurationAndComponent {
    @Bean
    public Driver driver() {
        Driver driver = new Driver();
        driver.setId(1);
        driver.setName("driver");
        driver.setCar(car());
        return driver;
    }

    @Bean
    public Car car() {
        Car car = new Car();
        car.setId(1);
        car.setName("car");
        return car;
    }
}
